<%@ page import="per.hnvcam.hedge.algebra.HedgeConstants" %>
<%@ page import="java.util.List" %>
<%@ page import="per.hnvcam.searchext.data.model.Rule" %>
<%@ page import="per.hnvcam.searchext.data.model.Condition" %>
<%@ page import="java.util.Set" %>
<%@ page import="per.hnvcam.searchext.data.model.RuleData" %>
<%@ page import="per.hnvcam.searchext.data.model.ConditionData" %>
<%@ page import="java.util.Map" %>
<%--
  Created by IntelliJ IDEA.
  User: camhoang
  Date: 8/2/11
  Time: 3:54 PM
  To change this template use File | Settings | File Templates.
--%>
<%@include file="include.jsp"%>
<%
   pageTitle = "Fuzzy Rule Set";
   configurationTile = "Rule Set";
%>
<%@include file="header.jsp"%>

<a href="#classifyRules">Go to classify rule set</a>


<h3><a href="<c:url value='/administration/rules.jhtml?operation=OPERATION_GENERATE_BASE_RULES'/>">Generate Base
   Rules</a></h3>

<table border="1" cellpadding="3" cellspacing="0">
   <tr>
      <th>Base Rules</th>
   </tr>

   <%
      List<RuleData> baseRules = (List<RuleData>) request.getAttribute("baseRules");
      Map<String, String> classifiedClasses = (Map<String, String>) request.getAttribute("classifiedClasses");
      for (RuleData baseRule : baseRules) {%>
   <tr>
      <td>
            <span class="rule_condition_keyword">IF&nbsp;</span>
            <%
         List<ConditionData> conditionList = baseRule.getConditions();
         boolean first = true;
         for (ConditionData condition : conditionList) {
            if (!first) {%>
            <span class="rule_condition_keyword">AND&nbsp;</span>
            <%
            } else {
               first = false;
            } %>
            <span class="rule_condition_word"><%=condition.getWord()%></span> = <span class="rule_condition_value"><%=condition.getFuzzyAmount()%></span>&nbsp;
            <%
         }
         %>
            <span class="rule_condition_keyword">THEN&nbsp</span>class&nbsp;=&nbsp;
            <span class="rule_result"><%=classifiedClasses.get(baseRule.getClassifiedClass())%></span>
            <br/>

               </td>
      </tr>
            <%
      }
   %>

</table>

<br/>

<h3><a href="<c:url value='/administration/rules.jhtml?operation=OPERATION_GENERATE_CLASSIFY_RULES'/>">Generate Classify
   Rules</h3>

<c:if test="${not empty initialRuleSetSize}">
   <span class="status">Initial Rule Set Size: ${initialRuleSetSize}</span>
   <br/>
</c:if>

<c:if test="${not empty flooringRuleSetSize}">
   <span class="status">Floored Rule Set Size: ${flooringRuleSetSize}</span>
   <br/>
</c:if>

<c:if test="${not empty classifyRuleSetSize}">
   <span class="status">Classify Rule Set Size: ${classifyRuleSetSize}</span>
   <br/>
</c:if>
<br/>

<table border="1" cellpadding="3" cellspacing="0">
   <tr>
      <th><a name="classifyRules">Classify Rules</a></th>
   </tr>

   <%
      List<RuleData> classifyRules = (List<RuleData>) request.getAttribute("classifyRuleSet");
      if (classifyRules != null) {
      for (RuleData classifyRule : classifyRules) {%>
   <tr>
      <td>
            <span class="rule_condition_keyword">IF&nbsp;</span>
            <%
         List<ConditionData> conditionList = classifyRule.getConditions();
         boolean first = true;
         for (ConditionData condition : conditionList) {
            if (!first) {%>
            <span class="rule_condition_keyword">AND&nbsp;</span>
            <%
            } else {
               first = false;
            } %>
            <span class="rule_condition_word"><%=condition.getWord()%></span> = <span class="rule_condition_value"><%=condition.getFuzzyAmount()%></span>&nbsp;
            <%
         }
         %>
            <span class="rule_condition_keyword">THEN&nbsp</span>class&nbsp;=&nbsp;
            <span class="rule_result"><%=classifiedClasses.get(classifyRule.getClassifiedClass())%></span>
            <br/>
               </td>
      </tr>
            <%
      }
      }
   %>

</table>


<%@include file="footer.jsp"%>